
const _INSTANCE_ = Symbol('_API_PROXY_')



class ApiProxy{
  constructor(){
    if(ApiProxy[_INSTANCE_]) return ApiProxy[_INSTANCE_];

    this.name = 'hello api'


    ApiProxy[_INSTANCE_] = new Proxy(this,{
      get:function(target,key, receiver){
        if(target[key]==undefined){
          console.log(`没有[${key}]属性`)
          return null
        }
        //return target[key]
        return Reflect.get(target, key, receiver);
      },

      set: function (target, key, value, receiver) {
        console.log(`setting ${key}!`);
        //return target[key] = value;
        return Reflect.set(target, key, value, receiver);
      }

    })

    return ApiProxy[_INSTANCE_]
  }

  getName(){
    console.log(this.name)
  }


}





export default ApiProxy
